home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / CIFF.ZIP / CIFFMAN.TXT < prev    next >
Encoding:
Text File  |  1992-05-15  |  35.7 KB  |  1,092 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                          C Index File Functions (CIFF)
  19.                                  Version 1.00
  20.  
  21.                 Copyright (C) 1992 by Tini Software Group(TSG)
  22.                               All rights reserved
  23.  
  24.  
  25.           NOTICE
  26.           ------------------------
  27.  
  28.           Tini Software Group MAKES NO WARRANTY OF ANY KIND WITH REGARD TO
  29.           THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.           OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Tini
  31.           Software Group shall not be liable for errors contained herein or
  32.           for incidental consequential damages in connection with the
  33.           furnishing, performance, or use of this material.
  34.  
  35.           This document contains proprietary information which is protected
  36.           by copyright.  All rights reserved.
  37.  
  38.           The information contained in this document is subject to change
  39.           without notice.
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.           Contents
  49.           ------------------------
  50.  
  51.           CIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3
  52.  
  53.           Valid operations . . . . . . . . . . . . . . . . . . . . . . .  3
  54.  
  55.           ciff_open. . . . . . . . . . . . . . . . . . . . . . . . . . .  4
  56.  
  57.           ciff_close . . . . . . . . . . . . . . . . . . . . . . . . . .  5
  58.  
  59.           ciff_read. . . . . . . . . . . . . . . . . . . . . . . . . . .  6
  60.  
  61.           ciff_curr. . . . . . . . . . . . . . . . . . . . . . . . . . .  7
  62.  
  63.           ciff_first . . . . . . . . . . . . . . . . . . . . . . . . . .  8
  64.  
  65.           ciff_last. . . . . . . . . . . . . . . . . . . . . . . . . . .  9
  66.  
  67.           ciff_prev. . . . . . . . . . . . . . . . . . . . . . . . . . . 10
  68.  
  69.           ciff_next. . . . . . . . . . . . . . . . . . . . . . . . . . . 11
  70.  
  71.           ciff_gteq. . . . . . . . . . . . . . . . . . . . . . . . . . . 12
  72.  
  73.           ciff_gt. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
  74.  
  75.           ciff_lteq. . . . . . . . . . . . . . . . . . . . . . . . . . . 14
  76.  
  77.           ciff_lt. . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
  78.  
  79.           ciff_altkey. . . . . . . . . . . . . . . . . . . . . . . . . . 16
  80.  
  81.           ciff_write . . . . . . . . . . . . . . . . . . . . . . . . . . 17
  82.  
  83.           ciff_delete. . . . . . . . . . . . . . . . . . . . . . . . . . 18
  84.  
  85.           ciff_update. . . . . . . . . . . . . . . . . . . . . . . . . . 19
  86.  
  87.           ciff_error . . . . . . . . . . . . . . . . . . . . . . . . . . 20
  88.  
  89.                                                                Page 3
  90.  
  91.  
  92.           CIFF was designed to handle indexed records from within 'C'.
  93.           CIFF creates two files IndexFileName.IDX and IndexFileName.DAT.
  94.  
  95.           Records within CIFF may be accessed or retrieved through one or
  96.           more keys.  The keys and records can be variable length.
  97.  
  98.           There are two types of keys:
  99.                 1: primary key (only one is allowed)
  100.                 2: alternate keys (up to 3)
  101.           The value of the primary key distinguishes it from other primary keys
  102.           therefor this value must be unique from other primary keys.  Like
  103.           primary keys alternate key values must be unique form other alternate
  104.           keys of that type (i.e. alternate key1 can not be identical to any
  105.           other alternate key1, however, it can be identical to an alternate
  106.           key2 or alternate key3).  Alternate keys are used to look up records
  107.           and CAN NOT be used to add, delete or update records.  Once a key is
  108.           added it is not possible to change the value of the key, unless, the
  109.           record is deleted and re-entered.  The keys must be of type char and
  110.           no larger then 50 bytes.
  111.  
  112.           Records can be of any type and up to 32767 bytes.  When adding 
  113.           records to the index file it will increase the speed of CIFF
  114.           functions if the record size passed to ciff_write is large 
  115.           enough to hold an updated record.  
  116.  
  117.           Dos allows 20 files to be opened at once, 5 of these files are
  118.           reserved by DOS for system use, therefor the maximum number of 
  119.           index files opened at once is 7 (2 files are opened for each
  120.           index file).
  121.  
  122.           If CIFF is a test version the number of records in the index file
  123.           is limited to 20.
  124.  
  125.           CIFF Operation                      CIFF Function Call
  126.             Open an index file                 ciff_open
  127.             Close an index file                ciff_close
  128.             Read a record                      ciff_read
  129.             Read current record                ciff_curr
  130.             Read the first record              ciff_first
  131.             Read the last record               ciff_last
  132.             Read next record                   ciff_next
  133.             Read previous record               ciff_prev
  134.             Read greater than or equal to      ciff_gteq
  135.             Read greater than                  ciff_gt
  136.             Read less than or equal to         ciff_lteq
  137.             Read less than                     ciff_lt
  138.             Add an alternate key               ciff_altkey
  139.             Write a record                     ciff_write
  140.             Update a record                    ciff_update
  141.             Delete a record                    ciff_delete
  142.             Print a CIFF error message         ciff_error
  143.  
  144.  
  145.                                                                Page 4
  146.  
  147.  
  148.           Function ciff_open
  149.  
  150.           Syntax:
  151.                   int ciff_open(char *file_name, char *mode);
  152.  
  153.           Parameters:
  154.                   file_name       char *  Name of index file to open
  155.                                           (up to 8 characters).
  156.                   mode            char *  Access to the index file.
  157.  
  158.           Description:
  159.                   Open the index file Index file name.
  160.                   Mode used in calls to ciff_open is one of the following
  161.                   values:
  162.  
  163.                         r  - read only
  164.                         rw - read/write
  165.  
  166.                   If the index file does not exists and ciff_open was called
  167.                   with mode equal to "r" ciff_open will return an error, else
  168.                   if ciff_open was called using "rw" ciff_open will create the
  169.                   index file.
  170.  
  171.                   If the mode is "r" records CAN NOT be added, updated or deleted.
  172.                   
  173.                   On successful completion, CIFF_OPEN returns a non-negative
  174.                   integer (file handle).
  175.  
  176.           Return values:
  177.                   -1: Error creating index file
  178.                   -2: Error creating data file
  179.                   -3: Error opening index file
  180.                   -4: Error opening data file
  181.                   >0: File handle Number
  182.  
  183.           Example
  184.                   main()
  185.                   {
  186.                   int i,
  187.                       handle;
  188.  
  189.                   handle = ciff_open("CLIENTS", "rw");
  190.                   if(handle < 1)
  191.                      {
  192.                      ciff_error(handle);
  193.                      exit(1);
  194.                      }
  195.  
  196.                   i = ciff_close(handle);
  197.                   if(i)
  198.                      {
  199.                      ciff_error(i);
  200.                      exit(1);
  201.                      }
  202.                   }
  203.  
  204.                                                                Page 5
  205.  
  206.  
  207.           Function ciff_close
  208.  
  209.           Syntax:
  210.                   int ciff_close(int handle);
  211.  
  212.           Parameters:
  213.                   handle     int          file handle associated with
  214.                                           the index file to close.
  215.  
  216.           Description:
  217.                   Close the index file associated with handle.
  218.                   If handle is -1 ciff_close will close all
  219.                   index files opened.
  220.  
  221.           Return values:
  222.                   0: Success
  223.                  !0: Error
  224.  
  225.           Example
  226.                   main()
  227.                   {
  228.                   int i,
  229.                       handle;
  230.  
  231.                   handle = ciff_open("CLIENTS","rw");
  232.                   if(handle < 1)
  233.                      {
  234.                      ciff_error(handle);
  235.                      exit(1);
  236.                      }
  237.  
  238.                   i = ciff_close(handle);
  239.                   if(i)
  240.                      {
  241.                      ciff_error(i);
  242.                      exit(1);
  243.                      }
  244.                    }
  245.  
  246.                                                                Page 6
  247.  
  248.  
  249.           Function ciff_read
  250.  
  251.           Syntax:
  252.                   int ciff_read(int handle, char *key, void *record,
  253.                                 int key_number);
  254.  
  255.           Parameters:
  256.                   handle          int      Handle associated with the index file.
  257.                   key             char *   Pointer to key to read.
  258.                   record          void *   Pointer to record data.
  259.                   key_number      int      Key to use.
  260.  
  261.           Description:
  262.                   Return the record that corresponds to the key.  Key number
  263.                   is the key to use (0-Primary key, 1-Alternate key1,
  264.                   2-Alternate key2, 3-Alternate key3).
  265.  
  266.           Return values:
  267.                    0: Success
  268.                   -5: Record not found
  269.  
  270.           Example
  271.                   main()
  272.                   {
  273.                   char record[200];
  274.  
  275.                   int  i,
  276.                        handle;
  277.  
  278.                   handle = ciff_open("CLIENTS", "rw");
  279.                   if(handle < 1)
  280.                      {
  281.                      ciff_error(handle);
  282.                      exit(1);
  283.                      }
  284.  
  285.                   i = ciff_read(handle, "John Doe", record, 0);
  286.                   if (i)
  287.                      ciff_error(i);
  288.                   else
  289.                      printf("John Doe's address is %s",   record);
  290.  
  291.                   i = ciff_close(handle);
  292.                   if (i)
  293.                      {
  294.                      ciff_error(i);
  295.                      exit(1);
  296.                      }
  297.                   }
  298.                                                                Page 7
  299.  
  300.  
  301.           Function ciff_curr
  302.  
  303.           Syntax:
  304.                   int ciff_curr(int handle, char *key, void *record,
  305.                                 int key_number);
  306.  
  307.           Parameters:
  308.                   handle          int      Handle associated with the index file.
  309.                   key             char *   Pointer to key returned.
  310.                   record          void *   Pointer to record data.
  311.                   key_number      int      Key to use.
  312.  
  313.           Description:
  314.                   Read the current record. Key number is the key to use
  315.                   (0-Primary key, 1-Alternate key1, 2-Alternate key2,
  316.                   3-Alternate key3).
  317.  
  318.           Return values:
  319.                    0: Success
  320.                   -5: Record not found
  321.  
  322.           Example
  323.                   main()
  324.                   {
  325.                   char key[50],
  326.                        record[200];
  327.  
  328.                   int  i,
  329.                        handle;
  330.  
  331.                   handle = ciff_open("CLIENTS", "rw");
  332.                   if (handle < 1)
  333.                      {
  334.                      ciff_error(handle);
  335.                      exit(1);
  336.                      }
  337.  
  338.                   i = ciff_curr(handle, key, record, 0);
  339.                   if (i)
  340.                      ciff_error(i);
  341.                   else
  342.                      printf("%s's address is %s",key, record);
  343.  
  344.                   i = ciff_close(handle);
  345.                   if (!i)
  346.                      {
  347.                      ciff_error(i);
  348.                      exit(1);
  349.                      }
  350.                   }
  351.  
  352.                                                                Page 8
  353.  
  354.  
  355.           Function ciff_first
  356.  
  357.           Syntax:
  358.                   int ciff_first(int handle, char *key, void *record,
  359.                                  int key_number);
  360.  
  361.           Parameters:
  362.                   handle         int      Handle associated with the index file.
  363.                   key            char *   Pointer to key returned.
  364.                   record         void *   Pointer to record data.
  365.                   key_number     int      Key to use.
  366.  
  367.           Description:
  368.                   Read the first record. Key number is the key to use
  369.                   (0-Primary key, 1-Alternate key1, 2-Alternate key2,
  370.                   3-Alternate key3).
  371.  
  372.           Return values:
  373.                    0: Success
  374.                   -9: Empty index file
  375.  
  376.           Example
  377.                   main()
  378.                   {
  379.                   char key[50];
  380.                        record[200];
  381.  
  382.                   int  i,
  383.                        handle;
  384.  
  385.                   handle = ciff_open("CLIENTS", "rw");
  386.                   if (handle < 1)
  387.                      {
  388.                      ciff_error(handle);
  389.                      exit(1);
  390.                      }
  391.  
  392.                   i = ciff_first(handle, key, record, 0)
  393.                   if (i)
  394.                      ciff_error(i);
  395.                   else
  396.                      printf("%s's address is %s",key, record);
  397.  
  398.                   i = ciff_close(handle);
  399.                   if (i)
  400.                      {
  401.                      ciff_error(i);
  402.                      exit(1);
  403.                      }
  404.                   }
  405.  
  406.                                                                Page 9
  407.  
  408.  
  409.           Function ciff_last
  410.  
  411.           Syntax:
  412.                   int ciff_last(int handle, char *key, void *record,
  413.                                 int key_number);
  414.  
  415.           Parameters:
  416.                   handle         int      Handle associated with the index file.
  417.                   key            char *   Pointer to key returned.
  418.                   record         void *   Pointer to record data.
  419.                   key_number     int      Key to use.
  420.  
  421.           Description:
  422.                   Read the last record. Key number is the key to use
  423.                   (0-Primary key, 1-Alternate key1, 2-Alternate key2,
  424.                   3-Alternate key3).
  425.  
  426.           Return values:
  427.                    0: Success
  428.                   -9: Empty index file
  429.  
  430.           Example
  431.                   main()
  432.                   {
  433.                   char key[50];
  434.                        record[200];
  435.  
  436.                   int  i,
  437.                        handle;
  438.  
  439.                   handle = ciff_open("CLIENTS", "rw");
  440.                   if (handle < 1)
  441.                      {
  442.                      ciff_error(handle);
  443.                      exit(1);
  444.                      }
  445.  
  446.                   i = ciff_last(handle, key, record, 0);
  447.                   if (i)
  448.                      ciff_error(i);
  449.                   else
  450.                      printf("%s's address is %s",key, record);
  451.  
  452.                   i = ciff_close(handle);
  453.                   if (i)
  454.                      {
  455.                      ciff_error(i);
  456.                      exit(1);
  457.                      }
  458.                   }
  459.  
  460.                                                               Page 10
  461.  
  462.  
  463.           Function ciff_next
  464.  
  465.           Syntax:
  466.                   int ciff_next(int handle, char *key, void *record,
  467.                                 int key_number);
  468.  
  469.           Parameters:
  470.                   handle         int      Handle associated with the index file.
  471.                   key            char *   Pointer to key returned.
  472.                   record         void *   Pointer to record data.
  473.                   key_number     int      Key to use.
  474.  
  475.           Description:
  476.                   Read the next record. Key number is the key to use
  477.                   (0-Primary key, 1-Alternate key1, 2-Alternate key2,
  478.                   3-Alternate key3).
  479.  
  480.           Return values:
  481.                    0: Success
  482.                   -7: End of index file
  483.  
  484.           Example
  485.                   main()
  486.                   {
  487.                   char key[50],
  488.                        record[200];
  489.  
  490.                   int  i,
  491.                        handle;
  492.  
  493.                   handle = ciff_open("CLIENTS", "rw");
  494.                   if (handle < 1)
  495.                      {
  496.                      ciff_error(handle);
  497.                      exit(1);
  498.                      }
  499.  
  500.                   i = ciff_next(handle, key,record, 0);
  501.                   if (i)
  502.                      ciff_error(i);
  503.                   else
  504.                      printf("%s's address is %s",key, record);
  505.  
  506.                   i = ciff_close(handle);
  507.                   if (i)
  508.                      {
  509.                      ciff_error(i);
  510.                      exit(1);
  511.                      }
  512.                   }
  513.  
  514.                                                               Page 11
  515.  
  516.  
  517.           Function ciff_prev
  518.  
  519.           Syntax:
  520.                   int ciff_prev(int handle, char *key, void *record,
  521.                                 int key_number);
  522.  
  523.           Parameters:
  524.                   handle         int      Handle associated with the index file.
  525.                   key            char *   Pointer to key returned.
  526.                   record         void *   Pointer to record data.
  527.                   key_number     int      Key to use.
  528.  
  529.           Description:
  530.                   Read the previous record.  Key number is the key to
  531.                   use (0-Primary key, 1-Alternate key1, 2-Alternate
  532.                   key2, 3-Alternate key3).
  533.  
  534.           Return values:
  535.                    0: Success
  536.                   -8: Beginning of index file
  537.  
  538.           Example
  539.                   main()
  540.                   {
  541.                   char key[50],
  542.                        record[200];
  543.  
  544.                   int  i,
  545.                        handle;
  546.  
  547.                   handle = ciff_open("CLIENTS", "rw");
  548.                   if (handle < 1)
  549.                      {
  550.                      ciff_error(handle);
  551.                      exit(1);
  552.                      }
  553.  
  554.                   i =ciff_prev(handle, key, record, 0);
  555.                   if (i)
  556.                      ciff_error(i);
  557.                   else
  558.                      printf("%s's address is %s",key, record);
  559.  
  560.                   i = ciff_close(handle);
  561.                   if (i)
  562.                      {
  563.                      ciff_error(i);
  564.                      exit(1);
  565.                      }
  566.                   }
  567.  
  568.  
  569.                                                              Page 12
  570.  
  571.  
  572.           Function ciff_gteq
  573.  
  574.           Syntax:
  575.                   int ciff_gteq(int handle, char *key, void *record,
  576.                                 int key_number);
  577.  
  578.           Parameters:
  579.                   handle        int      Handle associated with the index file.
  580.                   key           char *   when called is pointer to key to find
  581.                                          on return is pointer to new key.
  582.                   record        void *   Pointer to record data.
  583.                   key_number    int      Key to use.
  584.  
  585.           Description:
  586.                   Get a record greater than or equal to key( key MUST be large
  587.                   enough to hold the returning key). Key number is the key to
  588.                   use (0-Primary key,  1-Alternate key1, 2-Alternate key2,
  589.                   3-Alternate key3).
  590.  
  591.           Return values:
  592.                    0: Success
  593.                   -7: Last record reached
  594.  
  595.           Example
  596.                   main()
  597.                   {
  598.                   char key[50],
  599.                        record[200];
  600.  
  601.                   int  i,
  602.                        handle;
  603.  
  604.                   handle = ciff_open("CLIENTS", "rw");
  605.                   if (handle < 1)
  606.                      {
  607.                      ciff_error(handle);
  608.                      exit(1);
  609.                      }
  610.  
  611.                   i =ciff_gteq(handle, key, record, 0);
  612.                   if (i)
  613.                      ciff_error(i);
  614.                   else
  615.                      printf("%s's address is %s", record);
  616.  
  617.                   i = ciff_close(handle);
  618.                   if (i)
  619.                      {
  620.                      ciff_error(i);
  621.                      exit(1);
  622.                      }
  623.                   }
  624.  
  625.                                                                Page 13
  626.  
  627.  
  628.           Function ciff_gt
  629.  
  630.           Syntax:
  631.                   int ciff_gt(int handle, char *key, void *record,
  632.                               int key_number);
  633.  
  634.           Parameters:
  635.                   handle       int      Handle associated with the index file.
  636.                   key          char *   when called is pointer to key to find
  637.                                         on return is pointer to new key value.
  638.                   record       void *   Pointer to record data.
  639.                   key_number   int      Key to use.
  640.  
  641.  
  642.           Description:
  643.                   Get a record greater than key (key MUST be large enough to
  644.                   hold the returning key). Key number is the key to use
  645.                   (0-Primary key,  1-Alternate key1, 2-Alternate key2,
  646.                   3-Alternate key3).
  647.  
  648.           Return values:
  649.                    0: Success
  650.                   -7: End of index file
  651.  
  652.           Example
  653.                   main()
  654.                   {
  655.                   char key[50],
  656.                        record[200];
  657.  
  658.                   int  i,
  659.                        handle;
  660.  
  661.                   handle = ciff_open("CLIENTS", "rw");
  662.                   if (handle < 1)
  663.                      {
  664.                      ciff_error(handle);
  665.                      exit(1);
  666.                      }
  667.  
  668.                   i = ciff_gt(handle, key, record, 0);
  669.                   if (i)
  670.                      ciff_error(i);
  671.                   else
  672.                      printf("%s's address is %s", record);
  673.  
  674.                   i = ciff_close(handle);
  675.                   if (i)
  676.                      {
  677.                      ciff_error(i);
  678.                      exit(1);
  679.                      }
  680.                   }
  681.  
  682.                                                                Page 14
  683.  
  684.  
  685.           Function ciff_lteq
  686.  
  687.           Syntax:
  688.                   int ciff_lteq(int handle, char *key, void *record,
  689.                                 int key number);
  690.  
  691.           Parameters:
  692.                   handle       int      Handle associated with the index file.
  693.                   key          char *   when called pointer to key to find
  694.                                         on return pointer to new key value.
  695.                   record       void *   Pointer to record returned.
  696.                   key_number   int      Key to use.
  697.  
  698.  
  699.  
  700.           Description:
  701.                   Get a record less than or equal to key (key MUST be large
  702.                   enough to hold the returning key). Key number is the key
  703.                   to use (0-Primary key,  1-Alternate key1, 2-Alternate key2,
  704.                   3-Alternate key3).
  705.  
  706.           Return values:
  707.                    0: Success
  708.                   -8: First record reached
  709.  
  710.           Example
  711.                   main()
  712.                   {
  713.                   char key[50],
  714.                        record[200];
  715.  
  716.                   int  i,
  717.                        handle;
  718.  
  719.                   handle = ciff_open("CLIENTS", "rw");
  720.                   if (handle < 1)
  721.                      {
  722.                      ciff_error(handle);
  723.                      exit(1);
  724.                      }
  725.  
  726.                   i = ciff_lteq(handle, key, record, 0);
  727.                   if (i)
  728.                      ciff_error(i);
  729.                   else
  730.                      printf("%s's address is %s", record);
  731.  
  732.                   i = ciff_close(handle);
  733.                   if (i)
  734.                      {
  735.                      ciff_error(i);
  736.                      exit(1);
  737.                      }
  738.                   }
  739.  
  740.                                                                Page 15
  741.  
  742.  
  743.           Function ciff_lt
  744.  
  745.           Syntax:
  746.                   int ciff_lt(int handle, char *key, void *record,
  747.                               int key number);
  748.  
  749.           Parameters:
  750.                   handle       int      Handle associated with the index file.
  751.                   key          char *   when called pointer to key to find
  752.                                         on return pointer to new key value.
  753.                   record       void *   Pointer to record returned.
  754.                   key_number   int      Key to use.
  755.  
  756.           Description:
  757.                   Get a record less than key (key MUST be large enough to
  758.                   hold the returning key). Key number is the key to use
  759.                   (0-Primary key,  1-Alternate key1, 2-Alternate key2,
  760.                   3-Alternate key3).
  761.  
  762.           Return values:
  763.                    0: Success
  764.                   -8: First record reached
  765.  
  766.           Example
  767.                   main()
  768.                   {
  769.                   char key[50],
  770.                        record[200];
  771.  
  772.                   int  i,
  773.                        handle;
  774.  
  775.                   handle = ciff_open("CLIENTS", "rw");
  776.                   if (handle < 1)
  777.                      {
  778.                      ciff_error(handle);
  779.                      exit(1);
  780.                      }
  781.  
  782.                   i = ciff_lt(handle, key, record, 0);
  783.                   if (i)
  784.                      ciff_error(i);
  785.                   else
  786.                      printf("%s's address is %s", record);
  787.  
  788.                   i = ciff_close(handle);
  789.                   if (i)
  790.                      {
  791.                      ciff_error(i);
  792.                      exit(1);
  793.                      }
  794.                   }
  795.  
  796.                                                                Page 16
  797.  
  798.  
  799.           Function ciff_altkey
  800.  
  801.           Syntax:
  802.                   int ciff_altkey(int handle, char *pri_key, char *alt_key,
  803.                                   int key_number);
  804.  
  805.           Parameters:
  806.                   handle       int      Handle associated with the index file.
  807.                   pri_key      char *   Pointer to primary key.
  808.                   alt_key      char *   Pointer to alternate key.
  809.                   key_number   int      Key to use.
  810.  
  811.           Description:
  812.                   Add alternate key to the index file. Key number is
  813.                   the key to use (1-Alternate key1, 2-Alternate key2,
  814.                   3-Alternate key3).
  815.  
  816.           Return values:
  817.                     0: Success
  818.                   -10: Duplicate alt key
  819.                   -11: Primary key not found
  820.                   -12: Error inserting alternate key
  821.  
  822.           Example
  823.                   main()
  824.                   {
  825.                   int handle;
  826.  
  827.                   handle = ciff_open("CLIENTS", "rw");
  828.                   if (handle < 1)
  829.                      {
  830.                      ciff_error(handle);
  831.                      exit(1);
  832.                      }
  833.  
  834.                   i = ciff_altkey(handle, "John Doe","187487754", 1);
  835.                   if (i)
  836.                      ciff_error(i);
  837.                   else
  838.                      printf("%s's address is %s", record);
  839.  
  840.                   i = ciff_close(handle);
  841.                   if (i)
  842.                      {
  843.                      ciff_error(i);
  844.                      exit(1);
  845.                      }
  846.                   }
  847.  
  848.                                                                Page 17
  849.  
  850.  
  851.           Function ciff_write
  852.  
  853.           Syntax:
  854.                   int ciff_write(int handle, char *key, void *record,
  855.                                  int rec_len);
  856.  
  857.           Parameters:
  858.                   handle       int      Handle associated with the index file.
  859.                   key          char *   Pointer to key to write.
  860.                   record       void *   Pointer to record returned.
  861.                   rec_len      int      Record length.
  862.  
  863.           Description:
  864.                   Write the record. Key is the primary key to the
  865.                   record, records CAN NOT be added with alternate keys.
  866.  
  867.           Return values:
  868.                    0: Success
  869.                   -6: Duplicate key
  870.  
  871.           Example
  872.                   main()
  873.                   {
  874.                   int i,
  875.                   handle;
  876.  
  877.                   handle = ciff_open("CLIENTS", "rw");
  878.                   if (handle < 1)
  879.                      {
  880.                      ciff_error(handle);
  881.                      exit(1);
  882.                      }
  883.  
  884.                   i = ciff_write(handle, "John Doe",
  885.                                 "1024 Gilroy Street, Scranton, PA 18505",
  886.                                 38);
  887.  
  888.                   if (i)  ciff_error(i);
  889.  
  890.                   i = ciff_close(handle);
  891.                   if (i)
  892.                      {
  893.                      ciff_error(i);
  894.                      exit(1);
  895.                      }
  896.                   }
  897.                                                                Page 18
  898.  
  899.  
  900.           Function ciff_update
  901.  
  902.           Syntax:
  903.                   int ciff_update(int file handle, char *key, void *record,
  904.                                   int rec_len);
  905.  
  906.           Parameters:
  907.                   handle       int      Handle associated with the index file.
  908.                   key          char *   Pointer to key to update.
  909.                   record       void *   Pointer to record returned.
  910.                   rec_len      int      Record length.
  911.  
  912.           Description:
  913.                   Update the record. Key must be the primary key to the
  914.                   record, records CAN NOT be updated with alternate keys.
  915.  
  916.           Return values:
  917.                    0: Success
  918.                   -5: Record not found
  919.  
  920.           Example
  921.                   main()
  922.                   {
  923.                   int handle;
  924.  
  925.                   handle = ciff_open("CLIENTS", "rw");
  926.                   if (handle < 1)
  927.                      {
  928.                      ciff_error(handle);
  929.                      exit(1);
  930.                      }
  931.  
  932.                   i = ciff_update(handle, "John Doe",
  933.                                    "1050 Main Street, Scranton, PA 18505",
  934.                                    36);
  935.  
  936.                   if (i)  ciff_error(i);
  937.  
  938.                   i = ciff_close(handle);
  939.                   if (i)
  940.                      {
  941.                      ciff_error(i);
  942.                      exit(1);
  943.                      }
  944.                   }
  945.  
  946.                                                                Page 19
  947.  
  948.  
  949.           Function ciff_delete
  950.  
  951.           Syntax:
  952.                   int ciff_delete(int handle, char *key);
  953.  
  954.           Parameters:
  955.                   handle       int      Handle associated with the index file.
  956.                   key          char *   Pointer to key to delete.
  957.  
  958.           Description:
  959.                   Delete the record.  Key is the primary key to the record,
  960.                   records CAN NOT be deleted with alternate keys.
  961.  
  962.           Return values:
  963.                    0: Success
  964.                   -5: Record not found
  965.  
  966.           Example
  967.                   main()
  968.                   {
  969.                   int  i,
  970.                        handle;
  971.  
  972.                   handle = ciff_open("CLIENTS", "rw");
  973.                   if (handle < 1)
  974.                      {
  975.                      ciff_error(handle);
  976.                      exit(1);
  977.                      }
  978.  
  979.                   i = ciff_delete(handle, "John Doe");
  980.                   if (i)  ciff_error(i);
  981.  
  982.                   i = ciff_close(handle);
  983.                   if (i)
  984.                      {
  985.                      ciff_error(i);
  986.                      exit(1);
  987.                      }
  988.                   }
  989.  
  990.                                                                Page 20
  991.  
  992.  
  993.           Function ciff_error
  994.  
  995.           Syntax:
  996.                   void ciff_error(int err_number);
  997.  
  998.           Parameters:
  999.                   err_number      int     Error number to print message for.
  1000.  
  1001.           Description:
  1002.                   Print the error message associated with error number
  1003.                   returned from a CIFF function.
  1004.  
  1005.           Errors:
  1006.                    -1: CIFF_ERR001 - Error creating index file
  1007.                    -2: CIFF_ERR002 - Error creating data file
  1008.                    -3: CIFF_ERR003 - Error opening index file
  1009.                    -4: CIFF_ERR004 - Error opening data file
  1010.                    -5: CIFF_ERR005 - Record not found
  1011.                    -6: CIFF_ERR006 - Duplicate record
  1012.                    -7: CIFF_ERR008 - First record reached
  1013.                    -8: CIFF_ERR007 - Last record reached
  1014.                    -9: CIFF_ERR009 - Empty index file
  1015.                   -10: CIFF_ERR010 - Primary key not found
  1016.                   -11: CIFF_ERR011 - Error inserting alternate key
  1017.                   -14: CIFF_ERR014 - Max index files opened
  1018.                   -15: CIFF_ERR015 - File handle not in use
  1019.                   -17: CIFF_ERR017 - Invalid key
  1020.                   -19: CIFF_ERR019 - Access denied
  1021.                   -22: CIFF_ERR022 - Test version - Maximum records exceeded
  1022.                     ?: CIFF_ERRUKN - Unknown error
  1023.           
  1024.           Example
  1025.                   main()
  1026.                   {
  1027.                   int handle;
  1028.  
  1029.                   handle = ciff_open("CLIENTS", "rw");
  1030.                   if (handle < 1)
  1031.                      {
  1032.                      ciff_error(handle);
  1033.                      exit(1);
  1034.                      }
  1035.  
  1036.                   i = ciff_close(handle);
  1037.                   if (i)
  1038.                      {
  1039.                      ciff_error(i);
  1040.                      exit(1);
  1041.                      }
  1042.                   }
  1043.  
  1044.          ----------------end-of-author's-documentation---------------
  1045.  
  1046.                          Software Library Information:
  1047.  
  1048.                     This disk copy provided as a service of
  1049.  
  1050.                            Public (software) Library
  1051.  
  1052.          We are not the authors of this program, nor are we associated
  1053.          with the author in any way other than as a distributor of the
  1054.          program in accordance with the author's terms of distribution.
  1055.  
  1056.          Please direct shareware payments and specific questions about
  1057.          this program to the author of the program, whose name appears
  1058.          elsewhere in  this documentation. If you have trouble getting
  1059.          in touch with the author,  we will do whatever we can to help
  1060.          you with your questions. All programs have been tested and do
  1061.          run.  To report problems,  please use the form that is in the
  1062.          file PROBLEM.DOC on many of our disks or in other written for-
  1063.          mat with screen printouts, if possible.  PsL cannot debug pro-
  1064.          programs over the telephone, though we can answer questions.
  1065.  
  1066.          Disks in the PsL are updated  monthly,  so if you did not get
  1067.          this disk directly from the PsL, you should be aware that the
  1068.          files in this set may no longer be the current versions. Also,
  1069.          if you got this disk from another vendor and are having prob-
  1070.          lems,  be aware that  some files may have become corrupted or
  1071.          lost by that vendor. Get a current, working disk from PsL.
  1072.  
  1073.          For a copy of the latest monthly software library newsletter
  1074.          and a list of the 3,000+ disks in the library, call or write
  1075.  
  1076.                            Public (software) Library
  1077.                                P.O.Box 35705 - F
  1078.                             Houston, TX 77235-5705
  1079.  
  1080.                                  Orders only:
  1081.                                 1-800-2424-PSL
  1082.                               MC/Visa/AmEx/Discover
  1083.  
  1084.                           Outside of U.S. or in Texas
  1085.                           or for general information,
  1086.                               Call 1-713-524-6394
  1087.  
  1088.                           PsL also has an outstanding
  1089.                           catalog for the Macintosh.
  1090.  
  1091.  
  1092.